<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Object.defineProperty</title>
</head>
<body>
    <script>
        let person = {
            name:'Jake',
            sex:'男',
        }
        Object.defineProperty(person,'age',{
            enumerable:true,  // 控制是否可以被枚举
            configurable:true, // 控制是否可以被删除
            // writable:true,    // 控制是否可以被修改，如果配置了value或者set属性，就不能写该配置项
            get(){
                return 12
            },
            set(val){
                if(val!==person['age']){
                    console.log('设置了新的属性值');
                    return val
                }
            }
        })
    </script>
</body>
</html>